iT邦幫忙

0

Day 13: 709. To Lower Case

  • 分享至 

  • xImage
  •  

Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

Example 1:
Input: s = "Hello"
Output: "hello"
Example 2:
Input: s = "here"
Output: "here"
Example 3:
Input: s = "LOVELY"
Output: "lovely"
解題思路
這題要求把字串中的所有大寫字母轉換成小寫字母。
1.內建方法toLowerCase()
或手動轉換:若字元在'A'到'Z'之間,轉成 (char)(c + 32)。
ASCII:
'A' = 65
'a' = 97
小寫字母比大寫多32
https://ithelp.ithome.com.tw/upload/images/20251015/20179424SzfL6PydHe.png


圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言